import { CloseCircleOutlined, SafetyCertificateOutlined } from '@ant-design/icons';

import React from 'react';
import { Tag } from 'antd';

/**
 * 成功或错误的结果标签
 * @param key 组件的唯一标识
 * @param success 是否成功
 * @returns
 */
export const SuccessOrError: React.FC<{ success: boolean }> = ({ success, children }) => {
  let tagProps = { icon: (<CloseCircleOutlined />), color: "error" };
  if (success) {
    tagProps = { icon: (<SafetyCertificateOutlined />), color: "success" };
  }
  return (<Tag key="successOrErrorTag" {...tagProps}>{children}</Tag>);
}
